package read;

import lejos.nxt.Button;
import lejos.nxt.ColorSensor;
import lejos.nxt.ColorSensor.Color;
import lejos.nxt.LCD;
import lejos.nxt.SensorPort;
import lejos.nxt.UltrasonicSensor;
import lejos.nxt.addon.EOPD;
import lejos.nxt.comm.RConsole;

public class ReadSensorsValue {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		RConsole.openBluetooth(40000);

		LCD.drawString("Connected", 0, 2);

		ColorSensor colorSensor = new ColorSensor(SensorPort.S1);
		UltrasonicSensor sonic = new UltrasonicSensor(SensorPort.S2);
		int inc = 0;

		while (!Button.ESCAPE.isPressed()) {
			inc++;
			Color color = colorSensor.getColor();
			RConsole.print(Integer.toString(inc));
			RConsole.print(" - ");
			RConsole.print(Integer.toString(color.getRed()));
			RConsole.print(", ");
			RConsole.print(Integer.toString(color.getGreen()));
			RConsole.print(", ");
			RConsole.print(Integer.toString(color.getBlue()));
			RConsole.print(", ");
			RConsole.println(Integer.toString(sonic.getDistance()));

			try {
				Thread.sleep(3000);
			} catch (InterruptedException e) {
				System.exit(0);
			}
		}

		RConsole.println("Closing...");

		RConsole.close();

	}

}
